/**
 * create 30san 2019-03-18 15:44
 * desc: 登录页面
 */

import React, {Component} from 'react';
import { connect } from 'react-redux';
import { actionCreators } from './store/index';
import {
    StyleSheet,
    Text,
    View,
    TextInput
} from 'react-native';

class LoginScreen extends Component {
    render() {
        return (
            <View style={styles.container}>
                <TextInput style={{width: 200, height: 50, borderWidth: 1, borderColor: 'gray'}}
                           value={this.props.account}
                />
                <Text onPress={() => this.props.clickLogin()} style={{marginTop: 10}}>登录</Text>
            </View>
        )
    }
}

const mapStateToProps = (state) => {
    return {
        account: state.loginReducer.defaultAcount
    }
};

const mapDispathToProps = (dispatch) => {
    return {
        clickLogin () {
            dispatch(actionCreators.clickLogin());
        },
    }
}


export default connect(mapStateToProps, mapDispathToProps)(LoginScreen);

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center'
    }
});